package com.ydgk.service.impl;

import com.ydgk.bean.KindsType;
import com.ydgk.dao.FurnitureMapper;
import com.ydgk.dao.KindsTypeMapper;
import com.ydgk.service.KindsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KindsTypeServiceImpl implements KindsTypeService{

    @Autowired
    private KindsTypeMapper kindsTypeMapper;

    @Autowired
    private FurnitureMapper furnitureMapper;

    public int insert(KindsType kindsType) {
        return kindsTypeMapper.insert(kindsType);
    }

    public List<KindsType> findAllByKid(int kid) {
        return kindsTypeMapper.findAllByKid(kid);
    }

    public KindsType findById(int ktid) {
        return kindsTypeMapper.findById(ktid);
    }

    public int deleteById(int ktid) {
        int i = furnitureMapper.findCountByKtid(ktid);
        if(i > 0){
            return 0;
        }else{
            return kindsTypeMapper.deleteById(ktid);
        }
    }

    public int updateById(KindsType kindsType) {
        return kindsTypeMapper.updateById(kindsType);
    }

    public KindsType findByKtname(String s) {
        return kindsTypeMapper.findByKtname(s);
    }
}
